<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件化的基本使用</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <!-- <h2>我是标题</h2>
        <p>我是内容</p>
        <p>我也是内容</p> -->
        <cpn1></cpn1>
        <cpn2></cpn2>
    </div>
    <script>
        //源代码是调用extend
        // const cpnConstructor = Vue.extend({
        //     template:`
        //         <div>
        //             <h2>我是标题</h2>
        //             <p>我是内容</p>
        //             <p>我也是内容</p>
        //         </div>`
        // })


        //语法糖注册全局组件
        Vue.component('cpn1', {
            template:`
                <div>
                    <h2>我是标题</h2>
                    <p>我是内容</p>
                    <p>我也是内容</p>
                </div>`
        })

        const app = new Vue({
            el: "#app",
            data: {
                
            },
            components:{//局部组件注册语法糖
                cpn2: {
                    template:`
                <div>
                    <h2>我是标题2</h2>
                    <p>我是内容</p>
                    <p>我也是内容</p>
                </div>`
                }
            }
        })
    </script>
</body>
</html>